package implementor;

import daoInterface.MaterialDao;
import dbhandeling.Crude;
import dto.Material;

public class MaterialImp extends Crude implements MaterialDao
{

String className=new Material().getClass().getName();

@Override
public void add(Material material) throws Exception
{
    insert(material);
}
/***********************************************************/

@Override
public void update(Material material) throws Exception
{

super.update(className,"catId",material.getCatId()+"","mCode",material.getmCode());
super.update(className,"mQuant",material.getmQuant()+"","mCode",material.getmCode());
super.update(className,"mMrp",material.getmMrp()+"","mCode",material.getmCode());
super.update(className,"sizeId",material.getsizeId()+"","mCode",material.getmCode());
super.update(className,"colorId",material.getcolorId()+"","mCode",material.getmCode());
super.update(className,"purchaseQuant",material.getpurchaseQuant()+"","mCode",material.getmCode());
super.update(className,"purchasePrice",material.getpurchasePrice()+"","mCode",material.getmCode());
super.update(className,"purchaseId",material.getpurchaseId()+"","mCode",material.getmCode());
super.update(className,"taxCode",material.gettaxCode()+"","mCode",material.getmCode());
}
/***********************************************************/

@Override
public void delete(Material material) throws Exception
{
super.delete(className,"mCode",material.getmCode());
}
/***********************************************************/

@Override
public Material retrieve(String conditionField,String conditionValue) throws Exception
{
Material material=(Material) super.retreive(className,conditionField,conditionValue);
return material;
}
/***********************************************************/

@Override
public Material[] retrieveArray(String conditionField,String conditionValue) throws Exception
{
Material[] material;
Object[] obj=super.retreiveArrayOnCondition(className,conditionField, conditionValue);
material=new Material[obj.length];
for(int i=0;i<material.length;i++)
{
material[i]=(Material) obj[i];
}
return material;
}
/***********************************************************/

@Override
public Material[] retrieveAll() throws Exception
{
Material[] material;
Object[] obj=super.retreiveAll(className);
material=new Material[obj.length];
for(int i=0;i<material.length;i++)
{
material[i]=(Material) obj[i];
}
return material;
}
/***********************************************************/
public int getAutoGenratedKey()
{
	 int key=super.getAutoGenratedKey(className,"") ;
	 return key;
}

}